| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var assert = require('chai').assert, |
||
| 4 | describe('Coverage', function(){ |
||
| 5 | |||
| 6 | it('Create plain', function(){ |
||
| 7 | assert.instanceOf(new GedcomX.Coverage(), GedcomX.Coverage, 'An instance of Coverage is not returned when calling the constructor with new.'); |
||
| 8 | assert.instanceOf(GedcomX.Coverage(), GedcomX.Coverage, 'An instance of Coverage is not returned when calling the constructor without new.'); |
||
| 9 | }); |
||
| 10 | |||
| 11 | it('Create with JSON', function(){ |
||
| 12 | var coverage = GedcomX.Coverage({ |
||
| 13 | spatial: { |
||
| 14 | original: 'A Place' |
||
| 15 | }, |
||
| 16 | temporal: { |
||
| 17 | formal: '+2015-01-03' |
||
| 18 | } |
||
| 19 | }); |
||
| 20 | assert.equal(coverage.getSpatial().getOriginal(), 'A Place'); |
||
| 21 | assert.equal(coverage.getTemporal().getFormal(), '+2015-01-03'); |
||
| 22 | }); |
||
| 23 | |||
| 24 | it('Create with mixed', function(){ |
||
| 25 | var coverage = GedcomX.Coverage({ |
||
| 26 | spatial: GedcomX.PlaceReference({ |
||
| 27 | original: 'A Place' |
||
| 28 | }), |
||
| 29 | temporal: GedcomX.Date({ |
||
| 30 | formal: '+2015-01-03' |
||
| 31 | }) |
||
| 32 | }); |
||
| 33 | assert.equal(coverage.getSpatial().getOriginal(), 'A Place'); |
||
| 34 | assert.equal(coverage.getTemporal().getFormal(), '+2015-01-03'); |
||
| 35 | }); |
||
| 36 | |||
| 37 | it('Build', function(){ |
||
| 38 | var coverage = GedcomX.Coverage() |
||
| 39 | .setSpatial(GedcomX.PlaceReference().setOriginal('A Place')) |
||
| 40 | .setTemporal(GedcomX.Date().setFormal('+2015-01-03')); |
||
| 41 | assert.equal(coverage.getSpatial().getOriginal(), 'A Place'); |
||
| 42 | assert.equal(coverage.getTemporal().getFormal(), '+2015-01-03'); |
||
| 43 | }); |
||
| 44 | |||
| 45 | it('toJSON', function(){ |
||
| 46 | var data = { |
||
| 47 | spatial: { |
||
| 48 | original: 'A Place' |
||
| 49 | }, |
||
| 50 | temporal: { |
||
| 51 | formal: '+2015-01-03' |
||
| 52 | } |
||
| 53 | }, coverage = GedcomX.Coverage(data); |
||
| 54 | assert.deepEqual(coverage.toJSON(), data); |
||
| 55 | }); |
||
| 56 | |||
| 57 | it('constructor does not copy instances', function(){ |
||
| 58 | var obj1 = GedcomX.Coverage(); |
||
| 59 | var obj2 = GedcomX.Coverage(obj1); |
||
| 60 | assert.strictEqual(obj1, obj2); |
||
| 61 | }); |
||
| 62 | |||
| 63 | }); |